package com.gscitysfy.cus.drain.modules.warning.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cus.drain.annotations.DictTranslation;
import com.gscitysfy.cus.drain.annotations.FieldParam;
import com.gscitysfy.cus.drain.constants.DicConstant;
import com.gscitysfy.cus.drain.modules.warning.entity.DrainSystemCommandLead;
import com.gscitysfy.cus.drain.modules.warning.entity.DrainWaringSystem;
import com.gscitysfy.cus.drain.modules.warning.service.IDrainSystemCommandLeadService;
import com.gscitysfy.cus.drain.modules.warning.service.IDrainWaringSystemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhangqiang
 * @since 2022-10-23 17:38:32
 */
@RestController
@RequestMapping("/warning/drainSystemManage")
public class DrainSystemCommandLeadController {

    @Autowired
    IDrainSystemCommandLeadService drainSystemCommandLeadService;


    /**
     * 获取体系相关
     * @return
     */
    @Operation(summary = "获取体系相关")
    @GetMapping("/page")
    @Parameters({
            @Parameter(required = false, name = "systemName", description = "体系名称"),
            @Parameter(required = false, name = "isEnable", description = "是否启用"),
            @Parameter(required = false, name = "systemType", description = "体系类型")
    })
    @DictTranslation({
            @FieldParam(dictType = DicConstant.SYSTEM_MANAGE_TYPE, targetField = "systemType")
    })
    public Result<Object> page(@Parameter(hidden = true) Page<DrainSystemCommandLead> page, @Parameter(hidden = true) DrainSystemCommandLead drainSystemCommandLead){
        return drainSystemCommandLeadService.getByPage(page, drainSystemCommandLead);
    }


    /**
     * 修改或者保存体系
     * @param drainSystemCommandLead
     * @return
     */
    @PostMapping("/save")
    @Operation(summary = "修改或者保存体系")
    @Parameters({
            @Parameter(required = false, name = "cmKid", description = "修改时必须，体系id"),
            @Parameter(required = false, name = "systemName", description = "新增时必须，体系名称"),
            @Parameter(required = false, name = "systemType", description = "新增时必须，体系类型"),
            @Parameter(required = false, name = "isEnable", description = "新增时必须，是否启用"),
            @Parameter(required = false, name = "systemFileId", description = "文件id")
    })
    public Result<Boolean> addOrUpdate(@Parameter(hidden = true)@RequestBody DrainSystemCommandLead drainSystemCommandLead ){
        return  Result.content(drainSystemCommandLeadService.saveOrUpdate(drainSystemCommandLead));
    }


    /**
     * 修改或者保存体系
     * @param drainSystemCommandLead
     * @return
     */
    @GetMapping("/del")
    @Operation(summary = "删除体系")
    @Parameters({
            @Parameter(required = false, name = "cmKid", description = "体系id")
    })
    public Result<Boolean> del(@Parameter(hidden = true) DrainSystemCommandLead drainSystemCommandLead ){

        return  drainSystemCommandLeadService.del(drainSystemCommandLead);
    }


    /**
     * 获取预警机制详情
     * @return
     */
    @Operation(summary = "获取体系列表或者详情")
    @GetMapping("/listOrDetail")
    @Parameters({
            @Parameter(required = false, name = "systemName", description = "体系名称"),
            @Parameter(required = false, name = "cmKid", description = "详情时必须，体系id"),
            @Parameter(required = false, name = "systemType", description = "体系类型")
    })
    @DictTranslation({
            @FieldParam(dictType = DicConstant.SYSTEM_MANAGE_TYPE, targetField = "systemType")
    })
    public Result<Object> listOrDetail(@Parameter(hidden = true) DrainSystemCommandLead drainSystemCommandLead){
        return drainSystemCommandLeadService.getListByQuery( drainSystemCommandLead);
    }
}
